package com.itheima2;

import java.util.ArrayList;
import java.util.Collections;

public class Work6 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("abcd");
        list.add("aaa");
        list.add("abc");
        list.add("dbca");
        Collections.sort(list, (o1, o2) -> {
            int num = o2.length() - o1.length();
             num =num==0? o1.compareTo(o2):num;
            num = num == 0 ? 1 : num;
            return num;
        });
        for (String s : list) {
            System.out.println(s);
        }
    }

}
